package win.larryzeal.spring.rmi.server.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.rmi.RmiServiceExporter;
import win.larryzeal.spring.rmi.common.service.HelloRMIService;

/**
 * Created by 张少昆 on 2017/8/23.
 */
@Configuration
public class RmiServerConfig {

    @Autowired
    private HelloRMIService helloRMIService;

    @Bean
    public RmiServiceExporter rmiServiceExporter(){
        RmiServiceExporter rmiServiceExporter = new RmiServiceExporter();
        rmiServiceExporter.setServiceName("helloRMI");
        //rmi实际使用的对象
        rmiServiceExporter.setService(helloRMIService);
        //rmi暴露给外部的访问接口
        rmiServiceExporter.setServiceInterface(HelloRMIService.class);
        //rmi访问的端口号是1919
        rmiServiceExporter.setRegistryPort(9999);

        rmiServiceExporter.setServicePort(1099);//这俩端口啥关系？

        return rmiServiceExporter;
    }
}
